#include"SDLPlayer.h"
#include<stdio.h>
#include<SDL\SDL.h>
SDL_Surface *screen=NULL;
SDL_Overlay *yuvlay=NULL;
void InitVideoThread(){
    if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER)<0){
        fprintf(stderr,"Couldn't initialize SDL:%s\n",SDL_GetError());
        return;
	}
    screen=SDL_SetVideoMode(352,288,32,SDL_HWSURFACE);
	SDL_Flip(screen);
    yuvlay=SDL_CreateYUVOverlay(352,288,SDL_IYUV_OVERLAY,screen);
}
void ClearVideoThread(){
//释放窗口
    if(screen)SDL_FreeSurface(screen);
//释放YUV数据
    if(yuvlay)SDL_FreeYUVOverlay(yuvlay);
//释放其它
	SDL_Quit();
}
void ShowOnePic(const char*data,int witdh,int height){
    SDL_Rect rect={0,0,witdh,height};
    memcpy(yuvlay->pixels[0],data,witdh*height*3/2);
    SDL_DisplayYUVOverlay(yuvlay,&rect);
}